package com.xueyi.system.ProductBatch.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xueyi.common.core.constant.basic.SqlConstants;
import com.xueyi.system.ProductBatch.domain.dto.ProductBatchDto;
import com.xueyi.system.ProductBatch.domain.po.ProductBatchPo;
import com.xueyi.system.ProductBatch.domain.query.ProductBatchQuery;
import com.xueyi.system.ProductBatch.manager.IProductBatchManager;
import com.xueyi.system.ProductBatch.mapper.ProductBatchMapper;
import com.xueyi.system.ProductBatch.service.IProductBatchService;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.system.batchManager.domain.po.BatchManagerPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品批次管理管理 服务层处理
 *
 * @author xueyi
 */
@Service
public class ProductBatchServiceImpl extends BaseServiceImpl<ProductBatchQuery, ProductBatchDto, IProductBatchManager> implements IProductBatchService {


    @Autowired
    private ProductBatchMapper productBatchMapper;

    /**
     * 查询产品批次管理对象列表 | 数据权限 | 附加数据
     *
     * @param productBatch 产品批次管理对象
     * @return 产品批次管理对象集合
     */
    @Override
    //@DataScope(userAlias = "createBy", mapperScope = {"ProductBatchMapper"})
    public List<ProductBatchDto> selectListScope(ProductBatchQuery productBatch) {
        return baseManager.selectListExtra(productBatch);
    }

    @Override
    public ProductBatchPo getProductBatch(String batch) {
        QueryWrapper<ProductBatchPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("batch",batch);
        queryWrapper.last(SqlConstants.LIMIT_ONE);
        ProductBatchPo batchManagerPo = productBatchMapper.selectOne(queryWrapper);
        return batchManagerPo;
    }
}
